package com.henry.Client;

/*
 *  编程实现客户端的初始化操作
 */

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.InetAddress;
import java.net.Socket;

public class ClientInitClose {
    private Socket s;
    private ObjectOutputStream oos;
    private ObjectInputStream ois;
    /*
     *  自定义成员方法实现客户端的初始化操作
     */

    public ObjectOutputStream getOos() {
        return oos;
    }

    public ObjectInputStream getOis() {
        return ois;
    }

    public void clientInit() throws IOException {
        s = new Socket(InetAddress.getLocalHost(), 8888);
        oos = new ObjectOutputStream(s.getOutputStream());
        ois = new ObjectInputStream(s.getInputStream());
        System.out.println("连接成功！");
    }
    /*
     *  自定义成员方法实现客户端的关闭操作
     */
    public void clientClose() throws IOException {
        ois.close();
        oos.close();
        s.close();
    }
}
